<template>
  <div class="home_one">
    <!--  图片轮播 -->
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(item, index) in bannerSwipe" :key="index">
        <img :src="item.banner_img" alt="">
      </van-swipe-item>
    </van-swipe>
    <!-- 课程导航 -->
    <div class="banner_one">
      <div class="div_dl" v-for="item in bannerList" :key="item.id" @click="detail(item)">
        <div><i :class="item.icon" id="icons"></i></div>
        <div>{{item.name}}</div>
      </div>
    </div>

    <div class="content_one">
      <!-- 体育资讯 -->
      <div class="count_1" v-for="item in contentList" :key="item.channel_info.id">
        <!-- 头部 -->
        <div class="content">
          <div class="reds"></div>
          <div class="fontsize">{{item.channel_info.name}}</div>
        </div>
        <!-- 明星讲师内容 -->
        <div class="content_two" v-for="it in item.list" :key="it.id">
          <div class="title_img">
            <img :src="it.teacher_avatar" :alt="it.title">
            <div>
              <p>{{it.teacher_name}}</p>
              <p>{{it.introduction}}</p>
            </div>
          </div>
        </div>

      </div>
    </div>
    <!-- 内容 -->

  </div>
</template>

<script>
// 按需引入“vant”
import { Swipe, SwipeItem } from "vant";
import { banner, cartlist } from "../../api/api"
export default {
  // 按需引入“vant”
  components: {
    [Swipe.name]: Swipe,
    [SwipeItem.name]: SwipeItem,
  },

  data () {
    return {
      show: false,
      bannerSwipe: [],
      contentList: [],
      bannerList: [
        { "id": "0", "icon": "icon iconfont icon-shuben_2", "name": "特色课" },
        { "id": "1", "icon": "icon iconfont icon-dianji", "name": "一对一辅导" },
        { "id": "2", "icon": "icon iconfont icon-jishiben", "name": "学习日历" },
      ]
    }
  },
  mounted () {
    banner().then(res => {
      //   console.log(res);
      this.bannerSwipe = res.data.data
      //   console.log(this.bannerSwipe);
    }),
      cartlist().then(res => {
        // console.log(res);
        this.contentList = res
        console.log(this.contentList);
      })
  },

  methods: {
    detail (id) {
      this.$router.push({ name: 'BannerDetail', params: { id } })
    }
  },
}
</script>

<style scoped>
.home_one {
  width: 100%;
  height: 100%;
  background: rgb(231, 228, 228);
}
.van-swipe-item img {
  width: 100%;
  height: 6rem;
}
.banner_one {
  width: 100%;
  display: flex;
  justify-content: space-around;
  position: absolute;
  top: 5rem;
}
.div_dl {
  width: 3rem;
  height: 3rem;
  background: white;
  box-shadow: 0px 0px 5px #fff;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.4rem;
}
.content_one {
  padding-left: 0.106667rem;
  padding-right: 0.106667rem;
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}
.count_1,
.count_2 {
  width: 100%;
}
.content {
  display: flex;
  align-items: center;
}
.reds {
  width: 0.04rem;
  background: red;
  height: 0.4rem;
  margin-right: 0.066667rem;
}
.fontsize {
  font-size: 0.4rem;
}
.content_two {
  width: 100%;
  height: 2.5rem;
  display: flex;
  margin-top: 0.4rem;
  background: white;
}
.title_img {
  display: flex;
  align-items: center;
}
.title_img img {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}
#icons {
  font-size: 1rem;
  color: rgb(218, 130, 30);
}
</style>